<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
    <meta name="generator" content="Jekyll v4.0.1">
    <title>Dashboard Template · Bootstrap</title>

    <link rel="canonical" href="https://getbootstrap.com/docs/4.5/examples/dashboard/">

    <!-- Bootstrap core CSS -->
    <link href="/static/css/bootstrap.css" rel="stylesheet">

    <style>
        .bd-placeholder-img {
            font-size: 1.125rem;
            text-anchor: middle;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }

        @media (min-width: 768px) {
            .bd-placeholder-img-lg {
                font-size: 3.5rem;
            }
        }
    </style>
    <!-- Custom styles for this template -->
    <link href="/static/css/dashboard.css" rel="stylesheet">
</head>
<body>

<!--引入导航-->
<div th:insert="~{commons/navbar::nav}"></div>

<div class="container-fluid">
    <div class="row">
        <!--引入侧边栏-->
        <div th:replace="commons/sidebar::#sidebarMenu(activeUri='emps')"></div>

        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">


            <h2>员工列表</h2>

            <a class="btn btn-sm btn-success" th:href="@{/emp}">添加</a>

            <div style="height: 10px;"></div>
            <div class="table-responsive">
                <table class="table table-striped table-sm">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th>Name</th>
                        <th>Age</th>
                        <th>Birth</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    <tr th:each="emp: ${emps}">
                        <td th:text="${emp.id}"></td>
                        <td>[[${emp.name }]]</td>
                        <td th:text="${emp.age}==true ? '男': '女'"></td>
                        <td th:text="${#dates.format(emp.birth, 'yyyy-MM-dd')}"></td>
                        <td>
                            <a class="btn btn-sm btn-primary" th:href="@{/emp/} + ${emp.id}">编辑</a>
                            <button class="btn btn-sm btn-danger btn-delete" th:attr="deleteUrl=@{/emp/} + ${emp.id}">删除</button>
                        </td>
                    </tr>

                    </tbody>
                </table>
            </div>
        </main>
    </div>

    <form id="deleteForm" action="/" method="post">
        <input type="hidden" name="_method" value="delete">
    </form>
    
</div>
<script src="/static/js/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
        crossorigin="anonymous"></script>
<!--<script>window.jQuery || document.write('<script src="../assets/js/vendor/jquery.slim.min.js"><\/script>')</script>-->
<script src="/static/js/bootstrap.bundle.js"></script>
<script src="/static/js/feather.min.js"></script>
<script src="/static/js/dashboard.js"></script>

<script>
    $(".btn-delete").click(function () {
        // 删除
        $("#deleteForm").attr("action", $(this).attr('deleteUrl')).submit();
        return false;
    })
</script>
</body>
</html>
